//
//  AppDelegate.m
//  AVPlayerViewController
//
//  Created by Xwoder on 17/2/3.
//  Copyright © 2017年 Xwoder. All rights reserved.
//

#import "AppDelegate.h"
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"movie" withExtension:@"mp4"];
    AVAsset *asset = [AVAsset assetWithURL:url];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
    AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
    
    AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
    playerViewController.player = player;
    // A Boolean value that indicates whether or not the receiver shows playback controls
    // playerViewController.showsPlaybackControls = YES;
    // videoGravity属性是对内部AVPlayerLayer实例的videoGravity属性的封装
    // playerViewController.videoGravity = AVLayerVideoGravityResizeAspect;
    
    UIWindow *window = [[UIWindow alloc] init];
    window.frame = [UIScreen mainScreen].bounds;
    window.rootViewController = playerViewController;
    [window makeKeyAndVisible];
    self.window = window;
    
    return YES;
}

@end
